/**
 * 
 */
package model;

import java.sql.ResultSet;
import myutil.Connect;

import vo.LoginInfoVo;

/**
 * @author Sony
 * 
 */
public class ForgotPasswordMo {
	public String getSecurityQuestion(String login_id, String site)
			throws Exception {
		Connect c = new Connect();
		//c.site = site;
		String question = null;
		ResultSet rs = c
				.getResult("select security_question from login_info where login_id='"
						+ login_id + "'");
		while (rs.next()) {
			question = rs.getString("security_question");
		}
		return question;

	}

/*	public String resetPassword(String login_id, String site, String password)
			throws Exception {
		Connect c = new Connect();
		c.site = site;
		String question = null;
		ResultSet rs = c
				.getResult("select security_question from login_info where login_id='"
						+ login_id + "'");
		while (rs.next()) {
			question = rs.getString("security_question");
		}
		return question;

	} */

	/*public boolean checkSecurityAnswer(LoginInfoVo vo, String site) {
		Connect c = new Connect();
		//c.site = site;
		ResultSet rs;
		try {
			rs = c.getResult("select * from login_info where login_id='"
					+ vo.getLogin_id() + "' and security_question_answer='"
					+ vo.getSecurity_question_answer() + "'");

			if (rs.next()) {
				return true;
			} else {
				return false;
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}

	}*/

	public void resetPassword(LoginInfoVo vo, String site) throws Exception {
		Connect c = new Connect();
		c.site = site;

		c.dml("update login_info set password='" + vo.getPassword()	+ "' where cid='" + vo.getCid() + "'");
	}

	public Boolean verifyLoginIdSite(String login_id, String site) {
		Connect c = new Connect();
		c.site = site;
		ResultSet rs;
		String query = "select * from login_info where login_id='" + login_id + "'";
		try {
			rs = c.getResult(query);
			if (rs.next()) {
				return true;
			} else {
				return false;
			}
		} catch (Exception e) {
			return false;
		}
	}
}
